package 矩阵;

/**
 * @author: TTDB
 * @create: 2025/9/15
 */
public class searchMatrix {
    public boolean searchMatrix(int[][] matrix, int target) {
        //从一个角开始贪心把
        int i = matrix.length - 1, j = 0;
        while (i >= 0 && j < matrix[0].length) {
            if (matrix[i][j] > target) i--;
            else if (matrix[i][j] < target) j++;
            else return true;
        }
        return false;
    }
}
